<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <title>XXXXXX</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'/>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <%@include file="/WEB-INF/pages/common/taglib.jsp" %>
    <%@include file="/WEB-INF/pages/common/common.jsp" %>
</head>
<body>
<div class="row-fluid" id="content-wrapper">
    <div class='span12'>
        <div class="row-fluid">
            <div class="span12">
                <div class="page-header">
                    <h1 class="pull-left">
                        <i class="icon-table"></i><span id="spanChange">XXXXXX</span>
                    </h1>

                    <div class="pull-right">
                        <ul class="breadcrumb">
                            <li><a><i class="icon-home"></i></a></li>
                            <li class="separator"><i class="icon-angle-right"></i></li>
                            <li class="active">XXXXXX</li>
                            <li class="separator"><i class="icon-angle-right"></i></li>
                            <li class="active">XXXXXX</li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div class='row-fluid'>
            <div class='span12 box bordered-box orange-border' style='margin-bottom: 0;'>
                <div class='row-fluid'>
                    <div class='span12 box'>
                        <div class='box-header blue-background'>
                            <div class='title'>
                                <i class='icon-edit'></i>
                                基本查询信息
                            </div>
                        </div>
                        <div class='box-content'>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0" style="margin-bottom: 10px;
 border-bottom: 1px solid #eee;">
                                <tr>
                                    <td style="text-align: left; padding-right: 10px; padding-left: 10px;">
                                        <button id="btnSearch" class='btn btn-primary btn-small'
                                                style='margin-bottom: 5px'>
                                            <i class='icon-search'></i>查 询
                                        </button>
                                        <button id="btnModify" class='btn btn-primary btn-small'
                                                style='margin-bottom: 5px'>
                                            <i class='icon-edit'></i>修 改
                                        </button>
                                        <button id="btnDelete" class='btn btn-primary btn-small'
                                                style='margin-bottom: 5px'>
                                            <i class='icon-remove'></i>删 除
                                        </button>
                                        <button class='btn btn-primary btn-small'
                                                onclick="ClearAllInput('SearchTable')"
                                                style='margin-bottom: 5px'>
                                            <i class='icon-trash'></i>重 置
                                        </button>
                                    </td>
                                </tr>
                            </table>
                            <table id="SearchTable" width="100%" border="0" cellspacing="0" cellpadding="5">
                                <tr>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    账册编号
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.eBillingNo"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    成品序号
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.goodsNo"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    成品名称
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.goodsName"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    成品规格
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.goodsModel"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    成品计量单位
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.goodsUnit"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    版本号
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.versionNo"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    对应料件序号
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.consumptionNo"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    对应料件名称
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.consumptionName"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    对应料件规格
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.consumptionModel"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    料件计量单位
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.consumptionUnit"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    单耗
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.consumption"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="width: 25%;">
                                        <table width="100%" border="0" cellspacing="10" cellpadding="0">
                                            <tr>
                                                <td class="titleCss">
                                                    损耗率
                                                </td>
                                                <td class="tdCss">
                                                    <input type="text" datafield="SearchTable.lossRate"/>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
                <div class='responsive-table'>
                    <table id="corptable">
                    </table>
                    <div id="corptablePage">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">

    function urlCode(cellvalue, options, rowObject) {
        cellvalue = cellvalue || '';
        cellvalue = $.trim(cellvalue);

        var url = '${basePath}/getTEBillingConsumptionDetail?id=' + rowObject.id;
        return "<a class='btn-link' href=\"" + url + "\">" + "<span style='color:#00acec'>" + cellvalue + "</span></a>";
    }

    $(function () {
        $("#corptable").jqGrid({
            datatype: "json",
            url: $basePath + "/eBilling/queryTEBillingConsumptionPage",
            colNames: [
                '账册编号',
                '成品序号',
                '成品名称',
                '成品规格',
                '成品计量单位',
                '版本号',
                '对应料件序号',
                '对应料件名称',
                '对应料件规格',
                '料件计量单位',
                '单耗',
                '损耗率',
            ],
            colModel: [
                {name: 'eBillingNo', index: 'eBillingNo'},
                {name: 'goodsNo', index: 'goodsNo'},
                {name: 'goodsName', index: 'goodsName'},
                {name: 'goodsModel', index: 'goodsModel'},
                {name: 'goodsUnit', index: 'goodsUnit'},
                {name: 'versionNo', index: 'versionNo'},
                {name: 'consumptionNo', index: 'consumptionNo'},
                {name: 'consumptionName', index: 'consumptionName'},
                {name: 'consumptionModel', index: 'consumptionModel'},
                {name: 'consumptionUnit', index: 'consumptionUnit'},
                {name: 'consumption', index: 'consumption'},
                {name: 'lossRate', index: 'lossRate'},
            ],
            viewrecords: true,
            autowidth: true,
            height: 'auto',
            shrinkToFit: false,
            autoScroll: true,
            rowNum: 10, //每页显示记录数
            rowList: [10, 20, 100], //可调整每页显示的记录数
            rownumWidth: 35,
            multiselect: true,
            width: $('body').width(),
            pager: "#corptablePage", //分页工具栏
            loadComplete: function () {
                var rowNum = $(this).jqGrid('getGridParam', 'records');
                if (rowNum <= 0) {
                    if ($(this).parent().children('.norecords').length == 0)
                        $(this).parent().append("<div class=\"norecords\">暂无数据！</div>");
                    $(this).parent().children('.norecords').show();
                }
                else {//如果存在记录，则隐藏提示信息。
                    $(this).parent().children('.norecords').hide();
                }

                $("#corptable").setGridWidth($(window).width() - 2);
                $(".ui-jqgrid tr.ui-row-ltr td").css('text-align', 'center');
            }
        });
    });

    function reloadGrid() {
        var jsonStr = customFormToData("SearchTable");
        $("#corptable").jqGrid('setGridParam', {
            url: $basePath + "/eBilling/queryTEBillingConsumptionPage",
            postData: JSON.parse(jsonStr), //发送数据
            page: 1
        }).trigger("reloadGrid"); //重新载入
    }

    $(function () {
        $("#btnSearch").bind("click", function () {
            reloadGrid();
        });

        $("#btnModify").bind("click", function () {
            var jsonArr = getId("corptable");
            if (1 != jsonArr.length) {
                ShowMessages("对不起,您只能选中一条记录", "系统提示", "msgwaring", null, 0);
            } else {
                location.href = "${basePath}/getTEBillingConsumptionDetail?id=" + jsonArr[0].id;
            }
        });

        $("#btnDelete").bind("click", function () {
            var selectedId = $("#corptable").jqGrid("getGridParam", "selrow");
            if (!selectedId) {
                ShowMessages("对不起,您没有选中任何记录", "系统提示", "msgwaring", null, 0);
                return;
            }
            var selectedRowIds = $("#corptable").jqGrid("getGridParam", "selarrrow");

            if (!checkDeleteRows("corptable", ["", "1", "4"])) {
                return false;
            }

            showConfirm("确定要删除选中的记录吗?", "系统提示", function () {
                var len = selectedRowIds.length;
                var jsonSeqId = "";
                for (var i = 0; i < len; i++) {
                    var row = $("#corptable").jqGrid("getRowData", selectedRowIds[i]);
                    jsonSeqId += row.applicationIdZ;
                    jsonSeqId += ",";
                }

                jsonSeqId = jsonSeqId.substr(0, jsonSeqId.length - 1);
                $.ajax({
                    type: "post",
                    async: false,
                    dataType: "json",
                    url: $basePath + "/declare/deleteDeclare",
                    data: {"applicationIdZ": jsonSeqId + ""},
                    success: function (result) {
                        if (result) {
                            showOKMessage('删除成功!', '', function () {
                                reloadGrid();
                            });
                        } else {
                            ShowMessages("删除失败", "系统提示", "msgwaring", null, 0);
                        }
                    }
                });
            })
        });

        $("#btnReset").bind("click", function () {
            document.forms[0].reset();
        });
    });

</script>
</body>
</html>
